<template>
    <div class="aptitudeDetails">
        <h5>发布规则/协议</h5>
        <ul class="inp-ul">
            <li>
                <span class="title">*一级类目</span>
                <span  v-if="inpData.nameLevel1">{{inpData.nameLevel1}}</span>
            </li>
            <li v-if="inpData.nameLevel2">
                <span class="title">二级类目</span>
                <span>{{inpData.nameLevel2}}</span>
            </li>
            <li v-if="inpData.nameLevel3">
                <span class="title">三级类目</span>
                <span>{{inpData.nameLevel3}}</span>
            </li>
            <li>
                <span class="title">*名称</span>
                <span>{{inpData.name}}</span>
            </li>
            <li>
                <span class="title">*内容</span>
                <div class="text" v-html="inpData.content"></div>
            </li>
            <!-- <li v-show="type==1">
                <span>操作记录</span>
                <el-table :data="tableData"  style="width: 100%" border height="270">
                    <el-table-column  prop="date" label="内容" width="180"></el-table-column>
                    <el-table-column  prop="name"  label="编辑时间" width="180"></el-table-column>
                    <el-table-column  prop="address" label="编辑者"></el-table-column>
                </el-table>
            </li> -->
            <li v-show="type==2||type==3">
                <span>*是否上架</span>
                <span>是</span>
            </li>
        </ul>
        <div class="btn-box">
            <span v-show="type==2||type==3" class="my-btn btn2" @click="gocancel">取消</span>
            <span v-show="type==1" class="my-btn btn2" @click="goAptitude">返回</span>
            <span v-show="type==2||type==3" class="my-btn btn btn2 my-background" @click="releaseClick">发布</span>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            type:1,//1---详情，2---预览 ，3---添加预览
            inpData:'',//传入参数
        }
    },
    mounted(){
        this.type=this.$route.query.type
        if(this.type==1){this.inpData=this.$route.query.row}
        else if(this.type==2){this.inpData=this.$route.query.agreementEntity}
        else if(this.type==3){this.inpData=this.$route.query.inpData}
    },
    methods:{
        //返回塞罕云规则页面
        goAptitude(){
            this.$router.go(-1)
        },
        //取消预览
        gocancel(){
            if(this.type==3){
                this.$router.push({path:'/index/aptitudeAdd',query:{row:this.inpData}})
            }else if(this.type==2){
                this.$router.push({path:'/index/aptitudeEdit',query:{row:this.inpData}})
            }
        },
        //发布
        releaseClick(){
            var agreementEntity={
                	"categoryName": "",
                    "content": "",
                    "creationTime": '',
                    "id": 0,
                    "labelId": 0,
                    "name": "",
                    "pid": 0,
                    "status": 0,
                    "type": 0
            }
            agreementEntity.content=this.inpData.content
            agreementEntity.creationTime=Date.parse(new Date())/1000
            agreementEntity.name=this.inpData.name
            agreementEntity.pid=this.inpData.pid
            agreementEntity.status=this.inpData.status
            agreementEntity.type=this.inpData.type
            if(this.inpData.content&&this.inpData.name){
                this.axios({
                    url:'/operate/sys/Agreement/save',
                    method:'post',
                    data:JSON.stringify(agreementEntity),
                    headers: {'Content-Type': 'application/json;charset=UTF-8'}
                }).then(res=>{console.log(res.data)})
                this.$router.go(-2)
            }else{
                alert('请填写必填项')
            }
        },
    },
    watch:{
      
    }
}
</script>

<style scoped>
.inp-ul{
    width: 100%;
    margin-top: 30px;
    font-size: 15px;
}
.inp-ul>li{
    width: 100%;
    padding: 20px 0;
    display: flex;
    align-items: center;
}
.inp-ul>li>span:first-child{
    display: inline-block;
    text-align: right;
    width: 90px;
    margin-right: 35px;
}
.inp-ul>li:nth-child(7),.inp-ul>li:nth-child(5){
    align-items: flex-start;
}
.text{
    width: calc(100% - 130px);
}
.btn-box{
    display: flex;
    align-items: center;
    padding-left:125px;
    padding-top: 60px;
}
.btn{
    margin-left: 20px;
}
.btn2{
    width: 100px;
    text-align: center;
}
</style>